# -*- coding: utf-8 -*-
# @Time    : 2020/2/26 上午12:52
# @Author  : lilong
# @File    : model_frame.py


"""
抽象出监听模式的框架模型
"""


class Observer:
    """观察者的基类"""
    def update(self, observer, object):
        pass


class Observable:
    """被观察者的基类"""

    def __init__(self):
        self.__observers = []

    def addObserver(self, observer):
        self.__observers.append(observer)

    def removeObserver(self, observer):
        self.__observers.remove(observer)

    def notifyObservers(self, object=0):
        for o in self.__observers:
            o.update(self, object)

